const express = require('express');
const expressWs = require('express-ws');

//引入响应处理函数
const { handleResponse ,connectSuccResponse} = require("../common/index")

var router = express.Router();
expressWs(router);

router
  .ws('/', function (ws, req){
    const succRes = connectSuccResponse()
    ws.send(succRes)
    ws.on('message', function (params) {
        const res = handleResponse(params)
        // 业务代码
        ws.send(res)
        
    })
    ws.on("close",function(e){
      console.log("close connection")
    })
   })



module.exports = router;